package com.study.config;

import com.study.interceptor.LoginInterctptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 注册拦截器
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterctptor loginInterctptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //addPath。。。：要拦截的路径，exclude。。。要排除的路径
        //   /* 表示一级路径  /**表示任意级路径
        registry.addInterceptor(loginInterctptor).addPathPatterns("/**").excludePathPatterns("/login");
    }
}
